package org.hfy.controller;

import org.hfy.common.ApiResponse;
import org.hfy.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 示例控制器
 * 
 * @author hfy
 * @version 1.0
 */
@RestController
@RequestMapping("/hello")
public class HelloController {

    @Autowired
    private SystemService systemService;

    /**
     * 健康检查接口
     * 
     * @return 欢迎信息
     */
    @GetMapping
    public ApiResponse<String> hello() {
        return ApiResponse.success("欢迎使用PCB ERP管理系统！系统运行正常。");
    }

    /**
     * 系统状态接口
     * 
     * @return 系统状态信息
     */
    @GetMapping("/status")
    public ApiResponse<String> status() {
        boolean healthy = systemService.isHealthy();
        if (healthy) {
            return ApiResponse.success("系统运行状态正常", systemService.getSystemInfo());
        } else {
            return ApiResponse.error("系统运行异常");
        }
    }

    /**
     * 系统信息接口
     * 
     * @return 系统信息
     */
    @GetMapping("/info")
    public ApiResponse<String> info() {
        return ApiResponse.success(systemService.getSystemInfo());
    }
} 